package com.fanqiechaodan.visitor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fanqiechaodan
 * @Classname AnimalFeatureVisitor
 * @Description 具体访问者;记录特征
 */
public class AnimalFeatureVisitor implements Visitor {

    private List<String> features;

    public AnimalFeatureVisitor() {
        features = new ArrayList<>();
    }

    @Override
    public void visitor(Dog dog) {
        features.add("Dog:color=" + dog.getColor() + ",size=" + dog.getSize());
    }

    @Override
    public void visitor(Cat cat) {
        features.add("Car:sound=" + cat.getSound() + ",age=" + cat.getAge());
    }

    @Override
    public void visitor(Bird bird) {
        features.add("Bird:name=" + bird.getName() + ",habitat=" + bird.getHabitat());
    }

    public void printFeatures(){
        features.forEach(System.out::println);
    }
}
